package ocbn.remotelab.GUI;

import net.rim.device.api.system.*;
import net.rim.device.api.ui.component.*;

/**
 * Letting the  user to choose an action, wether respond or ignore. <br>
 * If the user chooses to respond, send the packet to the server.
 * (Note: fireEvent method has not yet been implemented.
 *  This feature be done in the future.)<br>
 * If the user chooses ignore, do nothing and close the dialog. <br>
 * <br>
 * This class also alerts the user by beeping and vibration <br>
 * @author c9zhuron
 */
public final class NotifyingGUI extends Dialog{

    /**
     * Two-element array containing tune data.
     * The array elements are the note frequency in hertz and
     * the duration of the note in milliseconds.
     */
    private final short[] ALERT_TUNE = {1000, 15, 1350, 15, 1320, 20, 1300
            , 20, 1250, 25, 12050, 35};

    /**
     * A Constructor that let the user chooses an action, wether response or
     * ignore.
     * @param s  The string message for the user.
     * @param choices The string array that contains response and ignore. 
     */
    public NotifyingGUI(String s, String choices[]){
        //Call the super class constructor.
        super(s, choices,//{Response,Ignore}
                 new int[] {Dialog.YES, Dialog.NO},//{Dialog.Yes, Dialog.No}
                Dialog.YES,
                Bitmap.getPredefinedBitmap(Bitmap.QUESTION));
        

        //Determines if this device provides buzzer support. IF it does,
        //then play the tune.
        if (Alert.isBuzzerSupported()){
            Alert.startBuzzer(ALERT_TUNE, 90, true);
        }

        //Determines if this device provides vibration support. IF it does,
        //then vibrate.
//        if (Alert.isVibrateSupported()){
//            Alert.startVibrate(100);
//        }
        /**
         * Note the vibration is turned off on the simulator due to its naseating
         * effect...
         */
    }
}
